import server from "./server";

export default {
    // 用户登录请求
    async userlogin(username, password) {
        return await server({
            data: {
                username: username,
                password: password
            },
            method: 'post',
            url: '/user/login'
        })
    },
    // 用户注册请求
    async userregister(RegisterForm, avatar) {
        return await server({
            data: {
                nick: RegisterForm.nick,
                signature: RegisterForm.signature,
                userAvatar: avatar,
                username: RegisterForm.username,
                password: RegisterForm.password
            },
            method: 'post',
            url: '/user/register'
        })
    },
    //  判断用户是否已经登录
    async checkLogin() {
        return await server({
            method: 'get',
            url: '/user/checkLogin'
        })
    },
    // 用户退出
    async userlogout() {
        return await server({
            method: 'post',
            url: '/user/logout'
        })
    },
    //  获取用户信息
    async getUserInfo() {
        return await server({
            method: 'get',
            url: '/user/getUserInfo'
        })
    },
    //  更新用户信息
    async editUser(editForm) {
        return await server({
            method: 'post',
            data: {
                nick: editForm.nick,
                signature: editForm.signature,
                userAvatar: editForm.userAvatar
            },
            url: '/user/editUser'
        })
    },
    // 根据id获取用户信息
    async getUserInfoById(id) {
        return await server({
            method: 'get',
            url: '/user/getUserInfoByUserId?userId=' + id
        })
    }
}